﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Common;

namespace DataAccessLayer
{
    public interface IUnitCodes
    {
        DataColumn[] GetUnitCodes();

    }

    public class RateManagement_DB : IUnitCodes
    {
        
        Database objDatabase = null;
        DbCommand ObjCommand = null;
        MethodResult ObjMethodResult = null;
        
        public RateManagement_DB()
        {
            DatabaseProviderFactory Objfactory = new DatabaseProviderFactory();
            objDatabase = Objfactory.CreateDefault();
        }

        public DataColumn[] GetUnitCodes()
        {
            List<SingleColumn> ObjLstSingleColumns = GenericUtility.GetSingleColumnData(GenericUtility.DEFAULTUNITCODES);
            DataColumn[] ArrDataColumn = new DataColumn[ObjLstSingleColumns.Count];
            int index = 0;
            foreach (SingleColumn column in ObjLstSingleColumns)
            {
                ArrDataColumn[index] = new DataColumn(column.CustomColumn, Type.GetType("System.String"));
                index++;
            }

            return ArrDataColumn;
        }

        public DataTable GenerateRateMasterStructure()
       {

           DataTable ObjDataTable = new Master_Items_DB().GetMasterItemsInDataTable("Group");

           foreach (DataColumn column in GetUnitCodes())
           {
               ObjDataTable.Columns.Add(column);
           }

           return ObjDataTable;

       }

    }
}
